package day03.am;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;

public class Demo02 {
    public static void main(String[] args) throws IOException {
        JFrame jFrame = new JFrame("捕鱼");
        jFrame.setSize(800,480);
        jFrame.setResizable(false);
        jFrame.setLocationRelativeTo(null);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Pool pool = new Pool();
        jFrame.add(pool);
        jFrame.setVisible(true);
    }
}//Demo02结束
//Pool开始
class Pool extends JPanel{
    BufferedImage bg ;//定义背景图
    public Pool() throws IOException {
        bg = ImageIO.read(new File("fish/images/bg.jpg"));
    }
    public void paint(Graphics g) {
        g.drawImage(bg,0,0,null);
    }
}//Pool结束
//Fish开始
class Fish{
    BufferedImage image;//图片
    int width;//鱼图片的宽
    int height;//鱼图片的高
    int x; //x坐标
    int y; //y坐标

    public Fish(String name) throws IOException {
        image = ImageIO.read(
                new File("fish/iamges/"+name+"_00.png"));
        width = image.getWidth();
        height = image.getHeight();
        Random r = new Random();
        x = r.nextInt(800-width);
        y = r.nextInt(480-height);
    }

}
//Fish结束
